package cn.sdut.training.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import cn.sdut.training.dao.BaseDao;
import cn.sdut.training.domain.Academy;
import cn.sdut.training.domain.Majore;
import cn.sdut.training.domain.Oj;
import cn.sdut.training.domain.Tag;
import cn.sdut.training.service.TrainingService;

@Service("trainingService")
public class TrainingServiceImpl implements TrainingService{

	@Resource
	private BaseDao<Academy> academyDao;//注入academyDao
	@Resource
	private BaseDao<Oj> ojDao;//注入OjDao
	@Resource
	private BaseDao<Majore> majoreDao;//
	@Resource
	private BaseDao<Tag> tagDao;
	
	
	@Override
	public void deleteAcademy(Long id) {
		academyDao.deleteEntity(academyDao.getEntity(id));
	}

	@Override
	public List<Academy> findAllAcademy() {
		return academyDao.findEntityByHQL("from Academy");
	}

	@Override
	public Academy getAcademyById(long id) {
		return academyDao.getEntity(id);
	}

	@Override
	public void saveAcademy(Academy academy) {
		academyDao.saveEntity(academy);
	}

	@Override
	public void updateAcademy(Academy academy) {
		academyDao.updateEntity(academy);
	}

	@Override
	public void deleteMajore(Long id) {
		majoreDao.deleteEntity(majoreDao.getEntity(id));
	}

	@Override
	public void deleteOj(Long id) {
		ojDao.deleteEntity(ojDao.getEntity(id));
	}

	@Override
	public List<Majore> findAllMajores() {
		return majoreDao.findEntityByHQL("from Majore");
	}

	@Override
	public List<Oj> findAllOj() {
		return ojDao.findEntityByHQL("from Oj");
	}

	@Override
	public Oj getOjById(Long id) {
		return ojDao.getEntity(id);
	}

	@Override
	public void saveMajore(Majore majore) {
		majoreDao.saveEntity(majore);
	}

	@Override
	public void saveOj(Oj oj) {
		ojDao.saveEntity(oj);
	}

	@Override
	public void updateOj(Oj oj) {
		ojDao.updateEntity(oj);
	}

	@Override
	public List<Tag> findAllTags() {
		return tagDao.findEntityByHQL("from Tag");
	}

	@Override
	public void deleteTag(Long id) {
		tagDao.deleteEntity(tagDao.getEntity(id));
	}

	@Override
	public Majore getMajoreById(Long majoreId) {
		return majoreDao.getEntity(majoreId);
	}

	@Override
	public Tag getTagById(Long id) {
		return tagDao.getEntity(id);
	}

	@Override
	public void saveTag(Tag tag) {
		tagDao.saveEntity(tag);
	}

	@Override
	public void updateTag(Tag tag) {
		tagDao.updateEntity(tag);
	}

}
